Address inconsistent behavior on flux_led component#14713
Address inconsistent behavior on flux_led component#14713amelchio merged 7 commits intohome-assistant:devfrom
Conversation
Correct issue with comparison that was preventing white value slider from being shown.
|
Was about to search for the previous PR to report some issue. For me, with an rgbw controller, turning it on resets the white channel to 0. Will this be fixed with this PR or should I do some more investigating? |
|
That is fixed with this PR.
…On Thu, May 31, 2018 at 5:21 AM tadly ***@***.***> wrote:
Was about to search for the previous PR to report some issue.
For me, with an rgbw controller, turning it on resets the white channel to
0.
In other words it does not "remember" it's previous value(s) (not sure if
this applies to other properties as well).
Will this be fixed with this PR or should I do some more investigating?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#14713 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAbs0D0Oq2lzK5uaNdcf-ueRz2KW3HApks5t38Q3gaJpZM4UUUZT>
.
|
|
There is one remaining issue here. White only is a valid use of this controller: https://www.amazon.com/gp/product/B01DY56N8U When wired as white only it no longer changes brightness by the brightness slider, it controls via the white_value slider. That is extremely non-intuitive to someone who can't wade through these merges/PRs. Perhaps it is time to add a "mode: white" to flux_led and properly map white_value <-> brightness for that use case? That would also make it work transparently with homekit. (all of which worked before the changes started on this train) I can always create a template light to accomplish this for myself, but good luck anyone in the future ever figuring that out. Thoughts? |
|
@mikebdotorg you can already set mode to one of Also, for |
|
@tadly - Understood for someone that has 'rgb' AND 'w' wires coming out of their controller that need to be modified. However, the scenario I am describing here is if someone ONLY wires the 'w' channel. The removal of I'm suggesting for those users that a "mode: white" is created and there is only a single slider called brightness as all other controls do not serve a purpose any longer. There is no rgb wired to control. For those users this change has broken functionality (automations, homekit, etc... that controlled brightness now fail to do so). |
|
@oblogic7 - thank you! I'll test tonight (MDT) and let you know. |
|
@oblogic7 - worked great. All functionality as expected. Can dim with brightness slider on white only in hass UI, and with homekit. Config as you stated: Thanks again. Looking forward to this being merged. |
|
I just noticed something else (I'm running 0.70.1) When you turn the lights on via hassio, they snap on immediately, rather than fade up. This is only true via home assistant - the Magic Wifi App has the fade behaviour for both on and off events. |
|
|
||
| # handle RGB mode | ||
| else: | ||
| self._bulb.setRgb(*tuple(rgb), brightness=brightness) |
There was a problem hiding this comment.
Could you confirm that calling turn_on(rgb=[5,0,0], brighness=None) will really set the RGB color to [5,0,0] and not to [255,0,0] or anything else deformed by the previous brightness settings you re-use on line 254 ?
There was a problem hiding this comment.
Finally had a chance to test this and I found some inconsistent behavior. However, it appears that it is not with the handling of the values by the flux component, but some issue with the way the values are passed into turn_on.
I used the following payload to test:
{
"entity_id": "light.test_led_1",
"rgb_color": [0,5,0]
}
rgb_color is being converted to hs_color before being passed into the turn_on method. The flux component then uses color_util.color_hs_to_RGB to convert into a tuple of rgb values. This conversion results in 0,255,0 for the payload above instead of the expected 0,5,0. This is the source of the inconsistent behavior that I'm experiencing.
The flux library will only recalculate rgb values if a numeric value is passed for brightness. If None is passed, then it does not recalculate. I am making a change so that existing brightness value is only passed if rgb is None. This should prevent unexpected recalculation of the brightness when brightness is not included on the payload.
I'm not familiar enough with HA internals to know where to fix the hs_color bug mentioned above.
There was a problem hiding this comment.
After digging through the discussion on #11288, I see that @amelchio calls out this bug specifically.
I'm still checking out the changes, but I don't think the fix will be implemented on components unless there have been updates since that PR was merged. Maybe a new method has been added that I haven't found yet? If not, it looks to me like it will require more changes to the conversion methods.
There was a problem hiding this comment.
Popping in because I was tagged. I did not read all of these comments and I don't have flux_led hardware. Still, if you have specific questions about how things should work, I might be able to help.
There was a problem hiding this comment.
@amelchio Are you aware of a fix or work around for the issue that you point out here: https://github.com/home-assistant/home-assistant/pull/11288/files/1ee6a9f786c0508a7079aa2eaf282e03b2b83c9d#r175284144
If not, do you know if it will be a component level change or if it will be more involved?
There was a problem hiding this comment.
After #11288, the intention is that rgb_color no longer changes the brightness. So turn_on(rgb=[5,0,0], brighness=None) and turn_on(rgb=[255,0,0], brighness=None) should act in the same way: set the light to red with the current brightness level.
This must be implemented in each light platform, like flux_led.py in this case, and
if brightness is None:
brightness = self.brightness
seems like a reasonable way to achive that.
There was a problem hiding this comment.
Great. That is how it was implemented. I will roll back the last change so that the current brightness is used. Thanks!
|
... as well would you mind to update the tests so they check the behaviour you broke in your previous PR's and are trying to fix in this one ? |
|
@pezinek The differences were in the library methods that were being used and different versions of the controllers handling the calls differently. I'm not sure what decreased the coverage though. Will check that out. |
…mediate on action
…alculation of passed rgb values.
| self._bulb.setRgb(*tuple(rgb), brightness=brightness) | ||
|
|
||
| if not self.is_on: | ||
| self._bulb.turnOn() |
There was a problem hiding this comment.
Can you confirm that self._bulb.getRgb() works even when the bulb is not turned on?
amelchio
left a comment
There was a problem hiding this comment.
Looks good.
It seems that all comments have been addressed so I will merge this tomorrow if nobody objects.
|
Seems this didn't make it into 0.72.1 |
|
Now merged. This is tricky enough that it should get some beta testing so I will not tag it for a hotfix. |
|
Well done, this mostly works. The only problem I'm observing is that the units when sent a 'scene state' from being off, they ignore the RGB value, and just turn on to their previous state. A second hit of the scene changes the RGB to the correct values. |
|
I've also noticed one more nitpick. If you have a RGBW controller and:
In other words, only if both sliders are at 0 the switch should turn off |
|
@kineticscreen Can you post the payload you are using for the service call? Maybe it is related to this? @tadly This is due to the way that HA couples brightness to on/off. When brightness is 0, HA calls turn_off. I did run into this when making the updates, but could not tell the difference between turn_off being called from the UI or service call vs when HA was calling it because brightness was 0. |
|
Please continue troubleshooting in an issue. We don't want discussion or troubleshooting in closed PRs. |


Description:
Corrects inconsistent behavior between different versions of Magic Home controllers that was introduced as part of recent PR to separate white level on the flux_led component. Rigorous testing done on two types of Magic Home LED controllers to confirm that behavior is now consistent.
Also adds white only mode that remaps white value to use brightness for instances where only W channel is connected on RGBW controller. This should restore compatibility with Homekit or other components that expect brightness to control white level in these cases.
Checklist:
tox. Your PR cannot be merged unless tests passPull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#5470